Ext.onReady(function(){
	ORG.initPage();
});

var ORG = {
		initPage: function(){
			Ext.create('Ext.container.Viewport', {
			    layout: 'border',
			    frame:false,
			    border:false,
			    items: [{
			    	region: 'west',
			        split: true,
			        width: "60%",
			        layout: 'fit',
			        items:[ORG.createRoleGrid()]
			    },{
			    	id: 'mainPanel',
			        region: 'center',
			        layout: 'fit',
			        items:[ORG.createRoleUserGrid()]
			    }]
			});
		},
		createRoleGrid: function(){
			var grid = Ext.create('Ext.com.bkfm.datagrid', {
				title: "角色",
				id: "role",
				objPath : "ROOT/XTGLPT/JCSJGL/JSXX/BLK_BASE_ROLES",
				border: true,
				orderby : ' ORDER BY ORDER_BY ASC'
			});
			grid.on("itemclick",function(obj,record){
				var records = grid.getSelectedRecords();
				if(records.length == 0){
					return;
				}
				var filter = " ROLE_RWID in (";
				for(i in records){
					if(i==0){
						filter += "'"+records[i].getId()+"'";
					}else{
						filter += ",'"+records[i].getId()+"'";
					}
				}
				filter +=")";
				Ext.getCmp("roleUserGrid").search(filter);
			});
			return grid;
		},
		createRoleUserGrid: function(){
			var grid = Ext.create('Ext.com.bkfm.datagrid', {
				title: "角色所属用户",
				id: "roleUserGrid",
				objPath : "ROOT/XTGLPT/JCSJGL/JSXX/BLK_ROLE_USERS",
				border: 0,
				frame: false
			});
			return grid;
		}
}